package ru.urfc.portal.ui.client.googlets.client;

import ru.urfc.portal.ui.client.BaseGooglet;
import ru.urfc.portal.ui.client.descriptor.GridDescriptor;
import ru.urfc.portal.ui.client.descriptor.GridField;
import ru.urfc.portal.ui.client.model.catalogs.NetLicenseState;
import ru.urfc.portal.ui.client.model.catalogs.NetState;
import ru.urfc.portal.ui.client.widgets.MegaGrid;

import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiTemplate;
import com.google.gwt.user.client.ui.Widget;

public class NetList extends BaseGooglet {

	@UiTemplate("RegularList.ui.xml")
	interface Binder extends UiBinder<Widget, NetList> {}
	private static Binder binder = GWT.create(Binder.class);

	@UiField MegaGrid grid;
	@UiField Element title;
	
	@Override
	protected void init() {
		initWidget(binder.createAndBindUi(this));
		title.setInnerText("Радиосети и разрешения на частоты");

		GridDescriptor descriptor = new GridDescriptor(NET_WITH_DEVICES_NUMBER, CLIENTS, getClientId(), NETS);
		descriptor.setAddFieldPathPrefix("net");
		GridField autoexpandColumnField =
		descriptor.addAnchorColumn("name", "id", PAGE_NET_DETAILS, "Наименование", 100);
		descriptor.addTextColumn("region", "Территория", 100);
		descriptor.addCIColumn("state/text", "state/code", NetState.class, "Статус", 100);
		descriptor.setAddFieldPathPrefix("net/currentLicense");
		descriptor.addTextColumn("number", "Разрешение №", 100);
		descriptor.addDateColumn("expireDate", "Срок действия", 100);
		descriptor.addCIColumn("state/text", "state/code", NetLicenseState.class, "Статус разрешения", 100);
		descriptor.setAddFieldPathPrefix("");
		descriptor.addIntColumn("nDevices", "РЭС", 50);
		
		createController(descriptor, grid);
        grid.setAutoExpandColumn(autoexpandColumnField.getName());
	}
	
}